package com.example.hw11ymlandproperties.pk05;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * @ConfigurationProperties：表示使用Bean对象读取配置项
 *     prefix:表示配置文件中多个key的公共开始部分
 *               比如app.name,这里app为前缀
 */

//创建普通的bean,非spring代理
@Configuration(proxyBeanMethods = false)
@ConfigurationProperties(prefix = "app")
public class AppBean {
    //key的名称与属性名相同，调用setxxx方法给属性名赋值
    private String name;
    private String owner;
    private Integer port;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getOwner() {
        return owner;
    }

    public void setOwner(String owner) {
        this.owner = owner;
    }

    public Integer getPort() {
        return port;
    }

    public void setPort(Integer port) {
        this.port = port;
    }

    @Override
    public String toString() {
        return "AppBean{" +
                "name = '" +name + '\''+
                ",owner='" + owner + '\''+
                ", port=" + port +
                '}';
    }
}
